@extends('layouts.console_header')

@section('title', '商家修改')

@section('resources')
    @parent
<link rel="stylesheet" href="{{env('CSS_DOMAIN')}}css/kalendae1.css?v={{env('CCS_VERSION')}}" type="text/css" charset="utf-8">
<link rel="stylesheet" href="{{env('CSS_DOMAIN')}}css/check_pc.css?v={{env('CCS_VERSION')}}">
<link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
<style>
    #shop_type{width: 70px;height: 25px;border: 1px solid #000;float: left;margin-top: 5px;margin-right: 20px;}
    #container{width: 870px;height: 400px;position: relative;}
    .k-out-of-month{opacity: 0;}
    #choose_time{position: absolute;top: 0;right: 10px;width: 100px;height: 30px;text-align: center;line-height: 30px;border: 1px solid #9955c6;color: #9955c6;cursor: pointer;z-index: 9;}
</style>
@endsection

@section('content')
<section class="user_list">
	<div style="border-bottom: 2px solid #9955c6;overflow: hidden;">
		<p class="fz_14 account_title fl" style="border: none;">
		    <span style="color: #7f7f7f;">
		        <a href="/console/index">首页></a>
		        商家版运营>
		        <a href="/console/shop/list?cityid={{$cityid}}">已上架商家列表></a>
		        <a href="/console/shop/get?cityid={{$cityid}}&shopid={{$shopid}}">商家详情></a>
		    </span>
		    <span class="co_violet">修改</span>
        </p>
		<a onclick="history.go(-1);" href="#"><p class="fr tc back_btn">返回</p></a>
	</div>
	@if($type == "basic")
	    <!-- 基本信息 -->
	    <form id="basic" action="" method="">
	        <input type="hidden" name="type" value="basic">
	        <input type="hidden" name="shopid" value="{{$shopid}}" />
	        <input type="hidden" name="cityid" value="{{$cityid}}" />
            <p class="shop_basic">
                <span>门店名称</span>
                <input type="text" name="name" value="{{$data['name']}}" />
            </p>
            <p class="shop_basic">
                <span>门店编号</span>
                <input type="text" name="code" value="{{$data['code']}}" readonly/>
            </p>
            <p class="shop_basic">
                <span>前台电话</span>
                <input type="text" name="contactnumber" value="{{$data['contactnumber']}}" />
            </p>
            <p class="shop_basic">
                <span>营业时间</span>
                <input type="text" name="businesshours" value="{{$data['businesshours']}}" />
            </p>
            <p class="shop_basic">
                <span>接收短信手机</span>
                <input type="text" name="smsphone" value="{{$data['smsphone']}}" />
            </p>
            <div class="demo">
                <lable style="margin-left: 50px;">所在地</lable>
                <span id="province" style="margin-left: 10px;">
                    <select class="select" name="shopprovinceid" onchange="showCity(this)">
                        <!--<option value="">--请选择省--</option>-->
                        {{--<option value="1" selected="selected">江西省</option>--}}
                        {{--<option value="2">辽宁省</option>--}}
                        {{--<option value="3">福建省</option>--}}
                    </select>
                </span>
                <span id="city">
                    <select class="select" name="shopcityid" onchange="showDistrict(this)">
                        {{--<option value="">--请选择城市--</option>--}}
                    </select>
                    <input type="hidden" name="shopcityname" value="{{$data['cityname']}}" />
                </span>
                <span id="district">
                    <select class="select" name="shopdistrictid" onchange="showBusinessArea(this)">
                        <option value="">--请选择区县--</option>
                    </select>
                    <input type="hidden" name="shopdistrictname" value="{{$data['districtname']}}" />
                </span>
                <span id="businessarea">
                    <select class="select" name="shopbusinessareaid" onchange="selectBusinessArea(this)">
                        <option value="">--请选择商圈--</option>
                    </select>
                    <input type="hidden" name="shopbusinessareaname" value="{{$data['businessareaname']}}" />
                </span>
            </div>
            <div style="clear: both;"></div>
            <p class="shop_basic">
                <span>门店地址</span>
                <input type="text" name="address" value="{{$data['address']}}">
            </p>
            <p class="shop_basic1">
                <span>经纬度</span>
                <input style="width: 100px;border-radius: 5px;" type="button" name="" value="修改经纬度" onclick="getLngAndlat()" />
                <!-- <input style="width: 100px;height: 30px;border-radius: 5px; margin-top: 4px;margin-left: 570px;" type="button" name="" value="保存" id="preserve" /> -->
                <input type="hidden" name="longitude" id="longitude" style="width:200px" value="{{$data['longitude']}}" placeholder="经度"/>
                <input type="hidden" name="latitude" id="latitude" style="width:200px" value="{{$data['latitude']}}" placeholder="纬度"/>
            </p>
            <div id="container"></div>
            <p class="shop_basic">
                <span>经营分类</span>
                <span id="firstclass" style="width: 150px;height: 36px;">
                    <select class="select" name="firstclassid" style="width: 135px" onchange="selectclass('first',this)">
                        <option value="0">--请选择一级分类--</option>
                        <option value="1">美食</option>
                        <option value="2">休闲娱乐</option>
                        <option value="3">生活服务</option>
                        <option value="4">酒店</option>
                        {{--<option value="5">旅游</option>--}}
                    </select>
                    <input type="hidden" name="firstclassname" value="{{$data['firstclassname']}}"/>
                </span>
                <span id="secondclass" style="width:150px;">
                    <select class="select" name="secondclassid" style="width: 135px" onchange="selectclass('second',this)">
                        <option value="0">--请选择二级分类--</option>
                    </select>
                    <input type="hidden" name="secondclassname" value="{{$data['secondclassname']}}" />
                </span>
            </p>
            <p class="shop_basic">
                <span>商家标签</span>
                <input type="text" name="label" value="{{$data['label']}}" maxlength="8" placeholder="选填，限八个字以内">
            </p>
            <p class="shop_basic">
                <span>商家简介</span>
                <textarea name="description" id="" cols="30" rows="10">{{$data['description']}}</textarea>
            </p>
            <div style="width: 1160px;margin: 20px 10px;" class="oh">
                <input class="sure fl" type="button" id="submit_basic" value="保存"/>
                <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
            </div>
        </form>
	@elseif($type == "photo")
	    <!-- 商家相册 -->
        <form id="photo" action="" method="">
            <input type="hidden" name="type" value="photo">
            <input type="hidden" name="shopid" value="{{$shopid}}">
            <input type="hidden" name="cityid" value="{{$cityid}}">
            <div class="shop_check_center">
                <h3>商家环境图</h3>
                <div class="shop_check_picture oh">
                    <span class="fl">商家主图<br>(必填,只能上传一张)</span>
                    <div class="form-group jingyzz oh">
                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
                            <input type="file"  id="logo_shop" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('logo_shopid','logo_shop','logo',client,'logo_shop','input[name="logo"]','.progress'); />
                            <span class="upload_pic fl">+上传商品图</span>
                            <div class="fl pictureshow" id="logo_shopid"></div>
                        </div>
                    </div>
                    <div class="progress">

                    </div>
                    <div class="show_shoppic oh">
                        <p class="fl">
                            <img src="{{env('IMAGE_DOMAIN')}}{{$data['logo']}}" alt="">
                            <img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt="">
                        </p>
                    </div>
                    <input type="hidden" name="logo" value="{{$data['logo']}}" />
                </div>
                <div class="shop_check_picture oh">
                    <span class="fl">其他环境图<br>(必填，最少3张，最多可19张)</span>
                    <div class="form-group jingyzz oh">
                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
                            <input type="file"  id="logo_pic" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviewsPhoto('logo_picid','logo_pic','photospath',client,'logo_pic',"input[name='photospath']","input[name='photoscount']"); />
                            <span class="upload_pic fl">+上传其他环境图</span>
                            <div class="fl pictureshow" id="logo_picid"></div>
                        </div>

                    </div>
                    <div class="progress_more">

                    </div>
                    <div class="show_shoppic oh" id="select_photos">
                    @if(count($data['photos'])>=1)
                        @foreach($data['photos'] as $photo)
                        <p class="fl">
                            <img src="{{env('IMAGE_DOMAIN')}}{{$photo}}" alt="">
                            <img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt="">
                        </p>
                        @endforeach
                    @endif
                    </div>
                    <input type="hidden" name="oldphotos" value="">
                    <input type="hidden" name="photospath" value="{{$data['photospath']}}" />
                    <input type="hidden" name="photoscount" value="{{$data['photoscount']}}" />
                </div>
                <div class="oh ">
                    <h3 class="fl">商品图(选填，最多可20件商品)</h3>
                </div>
                <ol class="shop_addnew_details fz_14">
                @if(count($data['goodsphotos'])>=1)
                @foreach($data['goodsphotos'] as $list)
                    <li>
                        @if(!isset($i))
                            <input type="hidden" name="goodsindex" value="{{$i=1}}">
                        @else
                            <input type="hidden" name="goodsindex" value="{{++$i}}">
                        @endif
                        <div class="oh shop_addnew_details_title"><h4 style="font-weight: normal;" class="fz_16 fl">商品{{$i}}</h4><span class="fr fz_16 co_red shop_delete">删除</span></div>
                        <p>
                            <span>商品名称</span>
                            <input class="shop_name" type="text" name="goodsname{{$i}}" value="{{$list['name']}}" placeholder="15字以内">
                        </p>
                        <p>
                            <span style="position: relative;top: -70px;">商品介绍</span>
                            <textarea name="goodsdescription{{$i}}" id="" cols="30" rows="10" placeholder="可不填，100字以内">{{$list['description']}}</textarea>
                        </p>
                        <div class="form-group jingyzz oh">
                            <label class="fl" style="width: 100px;">商品图</label>
                            <div class="oh fl pic_box_outer" style="margin-left: 0px;">
                                <input type="file"  id="logo{{$i}}" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('logoid{{$i}}','logo{{$i}}','goodsphoto{{$i}}',client,'logo{{$i}}',"input[name='goodsphoto{{$i}}']",'.progress{{$i}}'); />
                                <span class="upload_pic fl">+上传商品图</span>
                                <div class="fl pictureshow" id="logoid{{$i}}"></div>
                            </div>
                        </div>
                        <div class="progress{{$i}}">

                        </div>
                        <div class="show_shoppic oh">
                            <p class="fl">
                                <img src="{{env('IMAGE_DOMAIN')}}{{$list['url']}}" alt="">
                                <img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt="">
                            </p>
                        </div>
                        <input type="hidden" name="goodsphoto{{$i}}" value="{{$list['url']}}" />
                    </li>
                @endforeach
                @endif
                </ol>
                <p class="shop_addnew co_violet" style="margin-top: 20px;height: 50px;line-height: 50px;">+新增商品</p>
                <input type="hidden" name="goods" value="" >
            </div>
            <div style="width: 1160px;margin: 20px 10px;" class="oh">
                <input class="sure fl" type="button" id="submit_photo" style="background-color: #9955c6;" value="保存"/>
                <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
            </div>
        </form>
    @elseif($type == 'doublecalendar')
        <!--翻倍日-->
        <form  id="doublecalendar" action="" method="">
            <input type="hidden" name="type" value="doublecalendar">
            <input type="hidden" name="shopid" value="{{$shopid}}">
            <input type="hidden" name="cityid" value="{{$cityid}}">
            <div class="shop_doubleday">
                <h2 class="fz_22">翻倍日</h2>
                <p class="doubleday_set weekday_set">
                    <span style="margin-right: 10px;">每周翻倍日上限</span>
                    <span class="weekdoubleday">
                        <select class="select" name="weekdoubleday" style="width: 50px;height: 20px;border: 1px solid #000;">
                        @if($data['weekdoubleday'] == '1')
                            <option value="1" selected="selected">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                        @elseif($data['weekdoubleday'] == '2')
                            <option value="1">1</option>
                            <option value="2" selected="selected">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                        @elseif($data['weekdoubleday'] == '3')
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3" selected="selected">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                        @elseif($data['weekdoubleday'] == '4')
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4" selected="selected">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                        @elseif($data['weekdoubleday'] == '5')
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5" selected="selected">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                        @elseif($data['weekdoubleday'] == '6')
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6" selected="selected">6</option>
                            <option value="7">7</option>
                        @elseif($data['weekdoubleday'] == '7')
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7" selected="selected">7</option>
                        @else
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                            <option value="6">6</option>
                            <option value="7">7</option>
                        @endif
                        </select>
                    </span>
                    <span style="margin-left: 10px;">天</span>
                </p>
                <div id="double_date" style="margin: 10px 20px;position: relative;height: 100px;">
                    <p id="choose_time">选择日期</p>
                    <input name="event" style="border: 1px solid #000;width: 1200px;height: 80px;position: absolute;left: 0;opacity: 0;cursor: pointer;z-index: 10;" type="text" value="{{$shopevent}}" id="choose" onchange="change()">
                    <textarea  style="border: 1px solid #000;width: 1025px;height: 70px;position: absolute;top: 0;left: 0;z-index: 11;" name="" id="choose1" cols="30" rows="10">{{$shopevent}}</textarea>
                    <!-- <input readOnly="true" style="border: 1px solid #000;width: 850px;height: 40px;" type="text" value="" id="choose" style="font-size: 40px;width: 100%;"> -->
                </div>
                <div class="shop_doubleday" hidden>
                    <span class="doubleday_set">翻倍日期备注:</span>
                    <input type="text" name="remark" value="{{$data['eventremark']}}" style="outline:#000; border:1px solid black;height:30px;width:500px;border-radius:5px;">
                </div>
            </div>
            <div style="width: 1160px;margin: 50px 10px 0;" class="oh">
                <input class="sure fl" type="button" id="submit_doublecalendar" style="background-color: #9955c6;" value="保存"/>
                <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
            </div>
        </form>
    @elseif($type == 'payrules')
        <!-- 代付规则 -->
        <form id="payrules" action="" method="">
            <input type="hidden" name="type" value="payrules">
            <input type="hidden" name="shopid" value="{{$shopid}}">
            <input type="hidden" name="cityid" value="{{$cityid}}">
            <div style="margin-top: 30px;margin-left: 20px;">
                <h2 class="fz_18">代付规则</h2>
                <p class="doubleday_set today_consume">
                    <span style="margin-right: 10px;">当日消费次数</span>
                    <span class="buynumber">
                        <select class="select" name="buynumber" name="weekdoubleday" style="width: 50px;height: 20px;border: 1px solid #000;">
                        @if($data['buynumber'] == '0')
                            <option value="0" selected="selected">不限</option>
                            <option value="1" >1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                        @elseif($data['buynumber'] == '1')
                            <option value="0">不限</option>
                            <option value="1" selected="selected">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                        @elseif($data['buynumber'] == '2')
                            <option value="0">不限</option>
                            <option value="1">1</option>
                            <option value="2" selected="selected">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                        @elseif($data['buynumber'] == '3')
                            <option value="0">不限</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3" selected="selected">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                        @elseif($data['buynumber'] == '4')
                            <option value="0">不限</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4" selected="selected">4</option>
                            <option value="5">5</option>
                        @elseif($data['buynumber'] == '5')
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5" selected="selected">5</option>
                        @else
                            <option value="0">不限</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                            <option value="4">4</option>
                            <option value="5">5</option>
                        @endif
                        </select>
                    </span>
                    <span style="margin-left: 10px;">次/用户</span>
                </p>
                <div style="position: relative;overflow: hidden;height: 60px;">
                    <span style="margin-top: 20px;" class="fl">封顶金额</span>
                    <div class="slideThree" style="position: absolute;top: 0px;left: 100px;">
                        <input type="checkbox" value="1"  id="slideThree" name="" checked />
                        <label for="slideThree"></label>
                    </div>
                    <p class=" fending">
                        <input class="fz_16" style="width: 150px;height: 30px;border: 1px solid #000;margin-left: 200px;padding-left: 10px;margin-top: 10px;" type="text" name="maxsales" value="{{$data['maxsales']}}" placeholder="请输入≥300的数字">
                        <span>元封顶</span>
                    </p>
                </div>
                
                <div style="position: relative;overflow: hidden;height: 60px;">
                    <span style="margin-top: 20px;" class="fl">全场参与</span>
                    <div class="slideOne">
                        <input type="checkbox" value="" id="slideOne" name="" checked />
                        <label for="slideOne"></label>
                    </div>
                    <p class="allin" style="position: absolute;top: 0px;left: 260px;">
                        <span style="margin-top: 10px;">全场参与，除</span>
                        <input class="fz_16" style="width: 500px;height: 30px;border: 1px solid #000;padding-left: 10px;" type="text" name="notpartakegoods" value="{{$data['notpartakegoods']}}" placeholder="请输入不参与的内容"><span>不参与</span>
                    </p>
                </div>
                
                <p class="oh rules_bottom">
                    <span class="fl" style="line-height: 30px;width: 80px;margin-right: 20px;">发票</span>
                    <input class="fl" style="width: 200px;height: 30px;border: 1px solid #000;" type="text" name="invoice" value="{{$data['invoice']}}">
                </p>
                <p class="oh rules_bottom">
                    <span class="fl" style="width: 50px;">其他</span>
                    <select name="" id="shop_type" onchange="typechack(this)">
                        <option value="empty">请选择</option>
                        <option value="hotel">酒店</option>
                        <option value="restuarant">餐饮</option>
                        <option value="drink">饮料店</option>
                        <option value="clothing">服装店</option>
                        <option value="flower">花店</option>
                        <option value="bar">酒吧</option>
                        <option value="ktv">KTV</option>
                    </select>
                    <textarea class="fl" name="content" id="other" cols="30" rows="10">{{$data['content']}}</textarea>
                </p>
                <p class="oh rules_bottom">
                    <span class="fl" style="line-height: 30px;width: 80px;margin-right: 20px;">温馨提示</span>
                    <textarea class="rule_forsalf fl fz_13" name="tips"  disabled="disabled" readonly="readonly">为避免商品价格不实，翻贝网平台不显示商家价格，以用户和实体店最终议价为准，最后通过翻贝网代付。翻贝网热线：400-6989-820</textarea>
                </p>
            </div>
            <div style="width: 1160px;margin: 20px 10px;" class="oh">
                <input class="sure fl" type="button" id="submit_payrules" style="background-color: #9955c6;" value="保存"/>
                <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
            </div>
        </form>
    @elseif($type == 'payaccount')
        <!-- 收款帐号 -->
        <form id="payaccount" action="" method="">
            <input type="hidden" name="type" value="payaccount">
            <input type="hidden" name="shopid" value="{{$shopid}}">
            <input type="hidden" name="cityid" value="{{$cityid}}">
            <div>
                <h2 class="fz_18">收款账户</h2>
                <p class="oh shop_forpeo">
                    <span class="fl">持卡人</span>
                    <input class="fl" type="text" name="cardholder" value="{{$data['cardholder']}}">
                </p>
                <p class="oh shop_forpeo">
                    <span class="fl">身份证号</span>
                    <input class="fl" maxlength="18" type="text" name="cardholder" value="{{$data['idcard']}}">
                </p>
                <p class="oh shop_forpeo">
                    <span class="fl">银行账号</span>
                    <input class="fl" type="text" name="bankcard" value="{{$data['bankcard']}}">
                </p>
                <p class="oh shop_forpeo">
                    <span class="fl">银行名称</span>
                    <input type="text" name="bankname" value="{{$data['bankname']}}">
                </p>
                <p class="oh">
                    <input style="width: 100px;height: 30px;border-radius: 5px;" type="button" name="" value="查询" onclick="getbankname()" />
                </p>
                <p class="oh shop_forpeo">
                    <span class="fl">开户行</span>
                    <select name="bankprovince" id="bankprovince"  onchange="showBankCity(this)">
                        <option value="">--请选择省份--</option>
                        <option value="{{$data['bankprovince']}}" selected="selected">{{$data['bankprovince']}}</option>
                    </select>
                    <select name="bankcity" id="bankcity">
                        <option value="">--请选择城市--</option>
                        <option value="{{$data['bankcity']}}" selected="selected">{{$data['bankcity']}}</option>
                    </select>
                    <input style="width: 402px;" type="text" name="opencardbank" value="{{$data['opencardbank']}}" placeholder="请填入支行名称">
                </p>
            </div>
            <div style="width: 1160px;margin: 20px 10px;" class="oh">
                <input class="sure fl" type="button" id="submit_payaccount" style="background-color: #9955c6;" value="保存"/>
                <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
            </div>
        </form>
    @elseif($type == 'legalperson')
        <!-- 法人信息 -->
        <form id="legalperson" action="" method="">
            <input type="hidden" name="type" value="legalperson">
            <input type="hidden" name="shopid" value="{{$shopid}}">
            <input type="hidden" name="cityid" value="{{$cityid}}">
            <div>
                <h2 class="fz_18" style="margin: 20px;">法人/门店负责人信息</h2>
                <p class="oh shop_basic">
                    <span class="fl">负责人姓名</span>
                    <input class="fl" type="text" name="parentname" value="{{$data['parentname']}}">
                </p>
                <p class="oh shop_basic">
                    <span class="fl">商家登录帐号</span>
                    <input class="fl" type="text" name="parentmobile" value="{{$data['parentmobile']}}" readonly>
                </p>
                <p class="oh shop_basic">
                    <span class="fl">合约开始时间</span>
                    <input class="fl" type="date" name="contractstarttime" value="{{$contractstarttime}}" readonly />
                </p>
                <p class="oh shop_basic">
                    <span class="fl">合约截止时间</span>
                    <input class="fl" type="date" name="contractendtime" value="{{$contractendtime}}" readonly />
                </p>
            </div>
            <div style="width: 1160px;margin: 20px 10px;" class="oh">
                <input class="sure fl" type="button" id="submit_legalperson" style="background-color: #9955c6;" value="保存"/>
                <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
            </div>
        </form>
    @elseif($type == 'qualification')
        <!-- 经营资质 -->
        <form id="qualification" action="" method="">
            <input type="hidden" name="type" value="qualification">
            <input type="hidden" name="shopid" value="{{$shopid}}">
            <input type="hidden" name="cityid" value="{{$cityid}}">
            <div class="jingyzz">
                <h2 class="fz_18" style="margin: 20px;">经营资质</h2>
                <div class="oh" style="margin-bottom: 20px;">
                    <label class="fl" style="margin-right: 100px;">银行卡正面照</label>
                    <div class="form-group jingyzz oh">
                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
                            <input type="file"  id="bankcardphoto" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('bankcardphotoid','bankcardphoto','bankcardphoto',client,'bankcardphoto',"input[name='bankcardphoto']",'.progress_bankcard'); />
                            <span class="upload_pic fl">+上传收款账号的银行卡正面照</span>
                            <div class="fl pictureshow" id="bankcardphotoid"></div>
                        </div>
                    </div>
                    <div class="progress_bankcard">
                    </div>
                    <div class="show_shoppic oh">
                        <p class="fl">
                            <img src="{{env('IMAGE_DOMAIN')}}{{$data['bankcardphoto']}}" alt="">
                            <img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt="">
                        </p>
                    </div>
                    <input type="hidden" name="bankcardphoto" value="{{$data['bankcardphoto']}}" />
                </div>
                <div class="oh" style="margin-bottom: 20px;">
                    <label class="fl" style="margin-right: 100px;">上传营业执照</label>
                    <div class="form-group jingyzz oh">
                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
                            <input type="file"  id="licensephoto" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('licensephotoid','licensephoto','licensephoto',client,'licensephoto',"input[name='licensephoto']",'.progress_license'); />
                            <span class="upload_pic fl">+上传营业执照</span>
                            <div class="fl pictureshow" id="licensephotoid"></div>
                        </div>

                    </div>
                    <div class="progress_license">
                        
                    </div>
                    <div class="show_shoppic oh">
                        <p class="fl">
                            <img src="{{env('IMAGE_DOMAIN')}}{{$data['licensephoto']}}" alt="">
                            <img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt="">
                        </p>
                    </div>
                    
                    <input type="hidden" name="licensephoto" value="{{$data['licensephoto']}}" />
                </div>
                <div class="oh" style="margin-bottom: 20px;">
                    <label class="fl" style="margin-right: 100px;">身份证正面照</label>
                    <div class="form-group jingyzz oh">
                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
                            <input type="file"  id="idcardfrontphoto" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('idcardfrontphotoid','idcardfrontphoto','idcardfrontphoto',client,'idcardfrontphoto',"input[name='idcardfrontphoto']",'.progress_idcardfront'); />
                            <span class="upload_pic fl">+上传法人/门店负责人的身份证正面照</span>
                            <div class="fl pictureshow" id="idcardfrontphotoid"></div>
                        </div>

                    </div>
                    <div class="progress_idcardfront">
                        
                    </div>
                    <div class="show_shoppic oh">
                        <p class="fl">
                            <img src="{{env('IMAGE_DOMAIN')}}{{$data['idcardfrontphoto']}}">
                            <img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt="">
                        </p>
                    </div>
                    <input type="hidden" name="idcardfrontphoto" value="{{$data['idcardfrontphoto']}}" />
                </div>
                <div class="oh" style="margin-bottom: 20px;">
                    <label class="fl" style="margin-right: 100px;">身份证反面照</label>
                    <div class="form-group jingyzz oh">
                        <div class="oh fl pic_box_outer" style="margin-left: 0px;">
                            <input type="file"  id="idcardbackphoto" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('idcardbackphotoid','idcardbackphoto','idcardbackphoto',client,'idcardbackphoto',"input[name='idcardbackphoto']",'.progress_idcardback'); />
                            <span class="upload_pic fl">+上传法人/门店负责人的身份证反面照</span>
                            <div class="fl pictureshow" id="idcardbackphotoid"></div>
                        </div>

                    </div>
                    <div class="progress_idcardback">

                    </div>
                    <div class="show_shoppic oh">
                        <p class="fl">
                            <img src="{{env('IMAGE_DOMAIN')}}{{$data['idcardbackphoto']}}">
                            <img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt="">
                        </p>
                    </div>
                    
                    <input type="hidden" name="idcardbackphoto" value="{{$data['idcardbackphoto']}}" />
                </div>
            </div>
            <div style="width: 1160px;margin: 20px 10px;" class="oh">
                <input class="sure fl" type="button" id="submit_qualification" style="background-color: #9955c6;" value="保存"/>
                <input class="cancel fr" type="button" value="取消" onclick="history.go(-1);" />
            </div>
        </form>
    @endif
</section>
@endsection

@section('scriptResources')
    @parent
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.3&key=a9fe1b184bacd00ecd70365903024419&plugin=AMap.Autocomplete"></script>
    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
    <!--<script src="https://www.promisejs.org/polyfills/promise-6.1.0.js"></script>-->
    <script src="{{env('JS_DOMAIN')}}js/promise-6.1.0.js"></script> <!--放到本地-->
    <script src="https://gosspublic.alicdn.com/aliyun-oss-sdk-4.3.0.min.js"></script>
    <script src="{{env('JS_DOMAIN')}}js/kalendae.standalone1.js?v={{env('JS_VERSION')}}" type="text/javascript" charset="utf-8"></script>
    <script>
        'use strict';
        var OSS = OSS.Wrapper;
        var STS = OSS.STS;
        var client = new OSS({
            region: 'oss-cn-beijing',
            accessKeyId: '{{$AccessKeyId}}',
            accessKeySecret: '{{$AccessKeySecret}}',
            stsToken: '{{$SecurityToken}}',
            bucket: 'fbw',
            secure: true
        });
        var adminUserId = '{{$adminUserId}}';
        var cityid = '{{$cityid}}';
        var type = '{{$type}}';
        var shopid = '{{$shopid}}';
        var provinceid = '{{$provinceid}}';
        var content = '{{$content}}';
        var imagedomain = '{{env('IMAGE_DOMAIN')}}';
        var shopbusinessareaname;
        if(content == ""){
            $("#shop_type").val("empty");
        }else if(content.indexOf("每个ID仅限代付1间房；特价房、钟点房均可使用翻贝网代付") >= 0){
            $("#shop_type").val("hotel");
        }else if(content.indexOf("每桌仅限1位用户代付；茶位费、餐位费、主食均可使用翻贝网代付") >= 0){
            $("#shop_type").val("restuarant");
        }else if(content.indexOf("饮品类每个ID仅限代付2杯；其他不限") >= 0){
            $("#shop_type").val("drink");
        }else if(content.indexOf("每个ID仅限代付1件") >= 0){
            $("#shop_type").val("clothing");
        }else if(content.indexOf("每个ID仅限代付1束") >= 0){
            $("#shop_type").val("flower");
        }else if(content.indexOf("无代付封顶限制，所有店内消费均可使用使用翻贝网代付") >= 0){
            $("#shop_type").val("bar");
        }else if(content.indexOf("自选超市（零食、酒水、饮料）消费均可使用翻贝网代付") >= 0){
            $("#shop_type").val("ktv");
        }
        //获取经纬度
        var lnglatXY = [$("input[name='longitude']").val(),$("input[name='latitude']").val()]; //已知点坐标
        // var marker,map = new AMap.Map("container", {
        //     resizeEnable: true,
        //     center: lnglatXY,
        //     zoom: 20
        // });
        // function addMarker() {
        //     marker = new AMap.Marker({
        //         icon: "http://webapi.amap.com/theme/v1.3/markers/n/mark_r.png",
        //         position: lnglatXY
        //     });
        //     marker.setMap(map);
        // }
        // addMarker()
        var marker,map = new AMap.Map("container", {
            resizeEnable: true
        });
        function getLngAndlat() {
            var address = $("select[name='shopcityid']").find("option:selected").html() + $("select[name='shopdistrictid']").find("option:selected").html() + $("input[name='address']").val();
            if(address == '') {
                alert("请输入地址");
            }else{
                $.ajax({
                    url : '/console/lngandlat/get',
                    data:{"address":address},
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            var longitude = data.data.longitude;
                            var latitude = data.data.latitude;
                            $("input[name='longitude']").val(longitude);
                            $("input[name='latitude']").val(latitude);
                            lnglatXY = [$("input[name='longitude']").val(),$("input[name='latitude']").val()]; //已知点坐标
                            if (marker) {
                                marker.setMap(null);
                                marker = null;
                            }
                            marker = new AMap.Marker({  //加点
                                map: map,
                                position: lnglatXY
                            });
                            map.setFitView();
                            // }
                            function geocoder_CallBack(data) {
                                var address = data.regeocode.formattedAddress; //返回地址描述
                                document.getElementById("result").innerHTML = address;
                            }
                            //为地图注册click事件获取鼠标点击出的经纬度坐标
                            var clickEventListener = map.on('click', function(e) {
                                marker.setMap(null);
                                lnglatXY=[e.lnglat.getLng(),e.lnglat.getLat()]
                                // document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();
                                marker = new AMap.Marker({  //加点
                                    map: map,
                                    position: lnglatXY
                                });
                                map.setFitView();
                            });
                            // $("#preserve").click(function(){
                            // 	$("#longitude").val(lnglatXY[0]);
                            // 	$("#latitude").val(lnglatXY[1]);
                            // 	alert("保存成功");
                            // })
                            function select(e) {
                                if (e.poi && e.poi.location) {
                                    map.setZoom(15);
                                    map.setCenter(e.poi.location);
                                }
                            }
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
            }
        }


        function typechack(id){
            if($(id).val() == "empty"){
                $("#other").val("");
            }
            if($(id).val() == "hotel"){
                $("#other").val("每个ID仅限代付1间房；特价房、钟点房均可使用翻贝网代付；");
            }
            if($(id).val() == "restuarant"){
                $("#other").val("每桌仅限1位用户代付；茶位费、餐位费、主食均可使用翻贝网代付；");
            }
            if($(id).val() == "drink"){
                $("#other").val("饮品类每个ID仅限代付2杯；其他不限；");
            }
            if($(id).val() == "clothing"){
                $("#other").val("每个ID仅限代付1件；");
            }
            if($(id).val() == "flower"){
                $("#other").val("每个ID仅限代付1束；");
            }
            if($(id).val() == "bar"){
                $("#other").val("无代付封顶限制，所有店内消费均可使用使用翻贝网代付；");
            }
            if($(id).val() == "ktv"){
                $("#other").val("自选超市（零食、酒水、饮料）消费均可使用翻贝网代付；");
            }
        }

        var fending="{{$data['maxsales']}}";
        var allin="{{$data['notpartakegoods']}}";
        if (fending == 0 || fending == '') {
            $('.slideThree').css('background-color','#cdcdcd');
            $('.fending').hide();
            $('#slideThree').attr("checked",true);
            $("input[name='maxsales']").val(0);
        }else{
            $('.slideThree').css('background-color','#9955c6');
            $('.fending').show();
            $('#slideThree').attr("checked",false)
            // alert(0)
        }
        if (allin == '无' || allin == '') {
            $('.slideOne').css('background-color','#9955c6');
            $('.allin').hide();
            $('#slideOne').attr("checked",true)
        }else{
            $('.slideOne').css('background-color','#cdcdcd');
            $('.allin').show();
            $('#slideOne').attr("checked",false)
        }
        //封顶金额、全场参与   开关
        $('.slideThree label').click(function(){
            if($('.slideThree label').position().left==0){//开关打开
                $('.slideThree').css('background-color','#9955c6');
                $('.fending').show();
                $("input[name='maxsales']").val(fending);
            }else{//开关关闭
                $('.slideThree').css('background-color','#cdcdcd');
                $('.fending').hide();
                $("input[name='maxsales']").val(0);
            }
        })
        $('.slideOne label').click(function(){
            if($('.slideOne label').position().left==0){//开关打开
                $('.slideOne').css('background-color','#9955c6');
                $('.allin').hide();
                $("input[name='notpartakegoods']").val('');
            }else{//开关关闭
                $('.slideOne').css('background-color','#999');
                $("input[name='notpartakegoods']").val(allin);
                $('.allin').show();
            }
        })
            
        if(type == 'basic') {
            //修改基本信息
            //var cityarray = '{{$cityarray}}';
            var shopprovinceid = '{{$data['provinceid']}}';
            var shopcityid = '{{$data['cityid']}}';
            var shopcityname = '{{$data['cityname']}}';
            var shopdistrictname = '{{$data['districtname']}}';
            var shopdistrictid = '{{$data['districtid']}}';
            var shopbusinessareaid = '{{$data['businessareaid']}}';
            var shopbusinessareaname = '{{$data['businessareaname']}}';
            var firstclassanme = '{{$data['firstclassname']}}';
            var firstclassid = '{{$data['firstclassid']}}';
            var secondclassname = '{{$data['secondclassname']}}';
            var secondclassid = '{{$data['secondclassid']}}';
            var citystring = '<option value="'+shopcityid+'" selected="selected">'+shopcityname+'</option>';

            var firstclassstring = '<option value="0">--请选择一级分类--</option>'+
                                    '<option value="1">美食</option>'+
                                    '<option value="2">休闲娱乐</option>' +
                                    '<option value="3">生活服务</option>' +
                                    '<option value="4">酒店</option>';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":shopcityid,"type": 'district'},
                dataType:'json',
                async : false,
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择区县--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                        }
                        $("select[name='shopdistrictid']").html(areastring);
                        $("select[name='shopdistrictid']").find("option[value=" + shopdistrictid + "]").attr("selected",true);
                    }else {
                        alert(data.message)
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":shopdistrictid,"type": 'businessarea'},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择商圈--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                        }
                        $("select[name='shopbusinessareaid']").html(areastring);
                        $("select[name='shopbusinessareaid']").find("option[value=" + shopbusinessareaid + "]").attr("selected",true);
                    }else {
                        alert(data.message)
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
//            $("select[name='shopdistrictid']").html("<option value='" + shopdistrictid + "'>" + shopdistrictname + "</option>");
            $("select[name='shopcityid']").html(citystring);
//            $("select[name='shopbusinessareaid']").html("<option value='" + shopbusinessareaid + "'>"+shopbusinessareaname + "</option>");
            $("select[name='firstclassid']").html(firstclassstring);
            $("select[name='firstclassid']").find("option[value=" + firstclassid + "]").attr("selected",true);
            $("select[name='secondclassid']").html("<option value='" + secondclassid + "'>" + secondclassname + "</option>");
            getLngAndlat();
        } else if(type == 'photo') {
            //

        } else if(type == 'doublecalendar') {
            //日历
            var doubleday = new Kalendae.Input('choose', {
                months:12,
                mode:'multiple',
                direction:'future'
            });
            $("#choose_time").click(function(){
                $("#choose").focus();
            });
            $("#choose").scrollTop($("#choose1").height());
            var choose1_height = $("#choose1").height();
        } else if(type == 'payrules') {
            //

        } else if(type == 'payaccount') {
            var bankprovince = '{{$data['bankprovince']}}';
            var bankcity = '{{$data['bankcity']}}';
            showBankProvince(); //开通

        } else if(type == 'legalperson') {

        } else if(type == 'qualification') {
            //
        }

        function change(){
            $("#choose1").html($("#choose").val());
        };
        
        $("#submit_basic").click(function(){
            $("#longitude").val(lnglatXY[0]);
            $("#latitude").val(lnglatXY[1]);
            if($("select[name='shopbusinessareaid']").find("option:selected").val() == 0){
                shopbusinessareaname = '';
            };
            if($("select[name='shopdistrictid']").find("option:selected").val() == ''){
                alert('请选择区县');return;
            };
            $("input[name='shopbusinessareaname']").val(shopbusinessareaname);
            $.ajax({
                url : '/console/shop/edit',
                type : 'post',
                data: $('#basic').serialize(),
                dataType:'json',
                async:true,
                success:function(data){
                    window.location.href = '/console/shop/get?shopid=' + shopid + '&cityid=' + $("select[name='shopcityid']").val() + '&now=' + new Date().getTime();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
        $("#submit_photo").click(function(){
            var old_photos = '';
            var newshoppic = $("input[name='photoscount']").val();
            $('#select_photos p').each(function() {
                if($(this).css('display')!='none'){
                    var img=$(this).find('img').attr('src');
                    img = img.replace(imagedomain, '');
                    old_photos += img + ',';
                }
            });
            if(old_photos != '') {
                old_photos=old_photos.substring(0,old_photos.length-1);
            }
            $("input[name='oldphotos']").val(old_photos);
            var goodsstring='[';
            $('.shop_addnew_details li').each(function() {
            	var goodsindex=$(this).find("input[name='goodsindex']").val();
            	var goodsphoto=$("input[name='goodsphoto"+goodsindex+"']").val();
            	goodsphoto=goodsphoto.replace(imagedomain, '');
            	var goodsname = $("input[name='goodsname"+goodsindex+"']").val();
            	var goodsdescription=$("textarea[name='goodsdescription"+goodsindex+"']").val();
                goodsstring += '{"name":"'+goodsname+'","description":"'+goodsdescription+'","url":"'+goodsphoto+'"}'+',';
            });
            if(goodsstring != '[') {
                goodsstring=goodsstring.substring(0,goodsstring.length-1);
            }
            goodsstring += ']';
            $("input[name='goods']").val(goodsstring);
            var oldshoppic = old_photos.split(",");
            if((oldshoppic.length + newshoppic) < 3){
                alert("环境组图至少要上传3张");return;
            }else if(($('.shop_addnew_details li').length) < 3){
                alert("商品图至少要上传3张");return;
            }else {
                $.ajax({
                    url: '/console/shop/edit',
                    type: 'post',
                    data: $('#photo').serialize(),
                    dataType: 'json',
                    async: true,
                    success: function (data) {
                        window.location.href = '/console/shop/get?shopid=' + shopid + '&cityid=' + cityid + '&now=' + new Date().getTime();
                    },
                    error: function (XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
            }
        });
        $("#submit_doublecalendar").click(function(){
            $.ajax({
                url : '/console/shop/edit',
                type : 'post',
                data: $('#doublecalendar').serialize(),
                dataType:'json',
                success:function(data){
                    window.location.href = '/console/shop/get?shopid=' + shopid + '&cityid=' +cityid+ '&now=' + new Date().getTime();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
        $("#submit_payrules").click(function(){
            $.ajax({
                url : '/console/shop/edit',
                type : 'post',
                data: $('#payrules').serialize(),
                dataType:'json',
                async:true,
                success:function(data){
                    window.location.href = '/console/shop/get?shopid=' + shopid + '&cityid=' + cityid + '&now=' + new Date().getTime();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
        $("#submit_payaccount").click(function(){
            $.ajax({
                url : '/console/shop/edit',
                type : 'post',
                data: $('#payaccount').serialize(),
                dataType:'json',
                async:true,
                success:function(data){
                    window.location.href = '/console/shop/list?cityid=' +cityid +'&now=' + new Date().getTime();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
        $("#submit_legalperson").click(function(){
            $.ajax({
                url : '/console/shop/edit',
                type : 'post',
                data: $('#legalperson').serialize(),
                dataType:'json',
                async:true,
                success:function(data){
                    window.location.href = '/console/shop/get?shopid=' + shopid + '&cityid=' + cityid + '&now=' + new Date().getTime();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
        $("#submit_qualification").click(function(){
            $.ajax({
                url : '/console/shop/edit',
                type : 'post',
                data: $('#qualification').serialize(),
                dataType:'json',
                success:function(data){
                    window.location.href = '/console/shop/get?shopid=' + shopid + '&cityid=' + cityid + '&now=' + new Date().getTime();
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        });
        //显示省份
        showProvince();
        function showProvince() {
            var type='province';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":'',"type":type},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring;
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            if(list.id == provinceid) {
                                areastring += '<option value="' + list.id +'" selected="selected">' + list.name + '</option>';
                            }
                        }
                        $("#province").find("select").html(areastring);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        //显示城市
        function showCity(id) {
            var parentid = id.value;
            var type='city';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":parentid,"type":type},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择城市--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                        }
                        $("#city").find("select").html(areastring);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        //显示区县
        function showDistrict(id){
            var parentid = id.value;
            var type='district';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":parentid,"type":type},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择区县--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                        }
                        $("#district").find("select").html(areastring);
                        var shopcityname = $("select[name='shopcityid']").find("option:selected").text();
                        $("input[name='shopcityname']").val(shopcityname);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        //显示商圈
        function showBusinessArea(id) {
            var parentid = id.value;
            var type='businessarea';
            $.ajax({
                url : '/console/area/get',
                data:{"parentid":parentid,"type":type},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择商圈--</option>';
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list.id +'">' + list.name + '</option>';
                        }
                        $("#businessarea").find("select").html(areastring);
                        var shopdistrictname = $("select[name='shopdistrictid']").find("option:selected").text();
                        $("input[name='shopdistrictname']").val(shopdistrictname);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        function selectBusinessArea() {
            shopbusinessareaname = $("select[name='shopbusinessareaid']").find("option:selected").text();
            $("input[name='shopbusinessareaname']").val(shopbusinessareaname);
        }

        //获取二级
        function selectclass(type, id) {
            var parentid = id.value;
            if(type == 'first') {
                 $.ajax({
                    url : '/console/secondclass/get',
                    data:{"firstclassid":parentid},
                    type:'get',
                    dataType:'json',
                    success:function(data){
                        if(data.status == 'success') {
                            var data = data.data;
                            var secondclassstring = '<option value="">--请选择二级分类--</option>';
                            for(var i=0; i<data.length; i++) {
                                var list = data[i];
                                secondclassstring += '<option value="' + list.id +'">' + list.name + '</option>';
                            }
                            $("#secondclass").find("select").html(secondclassstring);
                        }
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) {
                        alert(XMLHttpRequest.status);
                        alert(XMLHttpRequest.readyState);
                        alert(textStatus);
                    }
                });
                var firstclassname = $("select[name='firstclassid']").find("option:selected").text();
                $("input[name='firstclassname']").val(firstclassname);
            } else if (type == 'second') {
                var secondclassname = $("select[name='secondclassid']").find("option:selected").text();
                $("input[name='secondclassname']").val(secondclassname);
            }
        }
        //获取银行名称
        function getbankname(){
            var bankcard = $("input[name='bankcard']").val();
            if(bankcard == '') {
                alert('银行卡不能为空');
            }
            $.ajax({
                url : '/console/bankname/get',
                data:{"bankcard":bankcard},
                dataType:'json',
                success:function(data){
                    if(data.status == 'success') {
                        var bankname = data.data;
                        $("input[name='bankname']").val(bankname);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        //开户行的城市
        function showBankProvince() {
            $.ajax({
                url : '/console/bank/province',
                data:{},
                dataType:'json',
                type:'get',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择省份--</option>' +
                                         '<option value="' + bankprovince + '" selected="selected">' + bankprovince + "</option>";
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list +'">' + list + '</option>';
                        }
                        $("#bankprovince").html(areastring);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        function showBankCity(id) {
            var parentname = id.value;
            $.ajax({
                url : '/console/bank/city',
                data:{"provincename":parentname},
                dataType:'json',
                type:'get',
                success:function(data){
                    if(data.status == 'success') {
                        var data = data.data;
                        var areastring = '<option value="">--请选择城市--</option>' +
                                         '<option value="' + bankcity + '" selected="selected">' + bankcity + "</option>";
                        for(var i=0; i<data.length; i++) {
                            var list = data[i];
                            areastring += '<option value="' + list +'">' + list + '</option>';
                        }
                        $("#bankcity").html(areastring);
                    }
                },
                error: function(XMLHttpRequest, textStatus, errorThrown) {
                    alert(XMLHttpRequest.status);
                    alert(XMLHttpRequest.readyState);
                    alert(textStatus);
                }
            });
        }
        //上传图片
        // var applyTokenDo1 = function (func) {
        //    return func(client,'logo1',"input[name='logo1']");
        // };
        var prog=$('<div id="progress-bar"class="progress-bar"role="progressbar"aria-valuenow="0"aria-valuemin="0"aria-valuemax="100" style="min-width: 1px;width: 0px;background: #9955c6;border-radius: 10px;margin: 10px 100px;padding-left: 10px;">0%</div>');
        var progress = function (p) {
            return function (done) {
                var bar = document.getElementById('progress-bar');
                bar.style.width = Math.floor(p * 600) + 'px';
                bar.style.backgroundColor = '#9955c6';
                bar.innerHTML = Math.floor(p * 100) + '%';
                done();

                if(p==1){
                    // $('#progress-bar').remove();
                    bar.style.width = 0+'px';
                    bar.innerHTML = 0 + '%';
                }
            }
        };
        var progress_all = function (p) {
            return function (done) {
                $('.progress_more').prepend(prog);
                var bar = document.getElementById('progress-bar');
                bar.style.width = Math.floor(p * 600) + 'px';
                bar.style.backgroundColor = '#9955c6';
                bar.innerHTML = Math.floor(p * 100) + '%';
                done();

                if(p==1){
                    // $('#progress-bar').remove();
                    bar.style.width = 0+'px';
                    bar.innerHTML = 0 + '%';
                }
            }
        };
        // 图片显示
        function setImagePreviews(avalue,inputid,picshow,client,id,ipt,pro) {
            $(pro).prepend(prog);
            var docObj = document.getElementById(inputid);
            var dd = document.getElementById(avalue);
            dd.innerHTML = "";
            var fileList = docObj.files;
            for (var i = 0; i < fileList.length; i++) {
                dd.innerHTML += "<div style='float:left' > <img id='"+ picshow + i + "'  /> </div>";
                var imgObjPreview = document.getElementById(picshow+i); 
                if (docObj.files && docObj.files[i]) {
                    //火狐下，直接设img属性
                    imgObjPreview.style.display = 'block';
                    imgObjPreview.style.width = '150px';
                    imgObjPreview.style.height = '180px';
                    //imgObjPreview.src = docObj.files[0].getAsDataURL();
                    //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
                    imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);
                }
                else {
                    //IE下，使用滤镜
                    docObj.select();
                    var imgSrc = document.selection.createRange().text;
                    alert(imgSrc)
                    var localImagId = document.getElementById(picshow + i);
                    //必须设置初始大小
                    localImagId.style.width = "150px";
                    localImagId.style.height = "180px";
                    //图片异常的捕捉，防止用户修改后缀来伪造图片
                    try {
                        localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                        localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
                    }
                    catch (e) {

                        alert("您上传的图片格式不正确，请重新选择!");
                        return false;
                    }
                    imgObjPreview.style.display = 'none';
                    document.selection.empty();
                }
            }
            var applyTokenDo1 = function (func) {
               return func(client,id,ipt);
            };
            applyTokenDo1(uploadLogo);
            return true;
        }
        //图片显示（批量）
        function setImagePreviewsPhoto(avalue,inputid,picshow,client,id,ipt1,ipt2) {
            var docObj = document.getElementById(inputid);
            var dd = document.getElementById(avalue);
            dd.innerHTML = "";
            var fileList = docObj.files;
            for (var i = 0; i < fileList.length; i++) {            
                dd.innerHTML += "<div style='float:left' > <img id='"+ picshow + i + "'  /> </div>";
                var imgObjPreview = document.getElementById(picshow+i); 
                if (docObj.files && docObj.files[i]) {
                    //火狐下，直接设img属性
                    imgObjPreview.style.display = 'block';
                    imgObjPreview.style.width = '150px';
                    imgObjPreview.style.height = '180px';
                    //imgObjPreview.src = docObj.files[0].getAsDataURL();
                    //火狐7以上版本不能用上面的getAsDataURL()方式获取，需要一下方式
                    imgObjPreview.src = window.URL.createObjectURL(docObj.files[i]);
                }
                else {
                    //IE下，使用滤镜
                    docObj.select();
                    var imgSrc = document.selection.createRange().text;
                    alert(imgSrc)
                    var localImagId = document.getElementById(picshow + i);
                    //必须设置初始大小
                    localImagId.style.width = "150px";
                    localImagId.style.height = "180px";
                    //图片异常的捕捉，防止用户修改后缀来伪造图片
                    try {
                        localImagId.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale)";
                        localImagId.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src = imgSrc;
                    }
                    catch (e) {

                        alert("您上传的图片格式不正确，请重新选择!");
                        return false;
                    }
                    imgObjPreview.style.display = 'none';
                    document.selection.empty();
                }
            }
            var applyTokenDo1 = function (func) {
               return func(client,id,ipt1,ipt2);
            };
            applyTokenDo1(uploadPhoto);
            return true;
        }
        //上传图片
        var uploadLogo = function (client,id,ipt) {
            var timestamp = new Date().getTime();
            var filePath= "temp/photos_" + adminUserId + "_" + timestamp; //文件路径：用户id＋时间戳
            var file = document.getElementById(id).files[0];
            var key = filePath;
            console.log('key:'+ key);
            client.multipartUpload(key, file, {
                progress: progress
            }).then(function (res) {
                // console.log('upload success: %j', res);
                $('#progress-bar').remove();
                $(ipt).val(key);
                // $().img('').attr('src', 'http://file.fbw-china.com/'+filePath);
            });
        };
        //批量上传
        var uploadPhoto = function (client,id,ipt1,ipt2,pro) {
            var timestamp = new Date().getTime();
            var filePath= "temp/photos_" + adminUserId + "_" + timestamp; //文件路径：用户id＋时间戳
            var docObj = document.getElementById(id);

            var count=docObj.files;
            for(var i=0; i<count.length; i++) {
                var file = document.getElementById(id).files[i];
                var key = filePath + "_" + i;
                console.log('key:'+ key);
                client.multipartUpload(key, file, {
                    progress: progress_all
                }).then(function (res) {
                    {{--var ps = '<p class="fl"><img src="' + res.url + '"><img class="pic_close" src="{{env('IMAGE_DOMAIN')}}images/access_delete.png?v={{env('IMAGE_VERSION')}}" alt=""> </p>';--}}
                    {{--$("#select_photos").append(ps)--}}
                     console.log('upload success: %j', res);
                    $('#progress-bar').remove();
                });
            }
            $(ipt1).val(filePath);
            $(ipt2).val(count.length);
            return true;
        };
        $(document).ready(function(){
            var num=$('.shop_addnew_details li').length;
            $('.shop_addnew').click(function(){
                // alert($('.shop_addnew_details').children('li').length)
                if($('.shop_addnew_details').children('li').length<20){
                    num+=1;
                    var li=$('<li><input type="hidden" name="goodsindex" value="'+num+'" /><div class="oh shop_addnew_details_title"><h4 style="font-weight: normal;" class="fz_16 fl">商品'+num+'</h4><span class="fr fz_16 co_red shop_delete">删除</span></div><p><span>商品名称</span><input class="shop_name" type="text" name="goodsname'+num+'" value="" placeholder="15字以内"></p><p><span style="position: relative;top: -70px;">商品介绍</span><textarea name="goodsdescription'+num+'" id="" cols="30" rows="10" placeholder="可不填，100字以内"></textarea></p><div class="form-group jingyzz oh"><label class="fl" style="width: 100px;">商家主图</label><div class="oh fl pic_box_outer" style="margin-left: 0px;"><input type="file"  id="logo'+num+'" multiple="multiple"  style="width:250px;height: 130px;" onchange=javascript:setImagePreviews('+"'logoid"+num+"','logo"+num+"','goodsphoto"+num+"',client,'logo"+num+"',"+'"'+"input[name='goodsphoto"+num+"']"+'",'+"'.progress"+num+"'"+'); /><span class="upload_pic fl">+上传商品图</span><div class="fl pictureshow" id="logoid'+num+'"></div></div></div><div class="progress'+num+'"></div><input type="hidden" name="goodsphoto'+num+'" value="" />');
                }else{
                    alert('商品图最多只能加20张')
                }
                $('.shop_addnew_details').append(li);
                $('#logo_button'+num).click(function() {
                    var applyTokenDo1 = function (func) {
                       return func(client,'logo'+num,"input[name='goodsphoto"+num+"']");
                    };
                    applyTokenDo1(uploadLogo);
                });
                $('.shop_delete').click(function(){
                    $(this).parent().parent().remove();
                });
            });
            $('.shop_delete').click(function(){
                $(this).parent().parent().remove();
            });
        })
        
        $('.show_shoppic .pic_close').click(function(){
            $(this).parent().hide();
        })
        //拖动排序
    </script>
@endsection